//
//  CTVMainMenuController.h
//  Channltv
//
//  Created by Bruno Keymolen on 06/09/07.
//  Copyright 2007 channl.tv. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <BackRow/BackRow.h>
#import "CTVSync.h"
#import "CTVRootChannel.h"
#import "CTVAutoUpdate.h"

typedef enum CTVMainMenuElementType{
	CTVMainMenuElementType_DEFAULT = 0,
	CTVMainMenuElementType_ROOTCHANNEL,
	CTVMainMenuElementType_SYNC,
	CTVMainMenuElementType_LineSeparator
}CTVMainMenuElementType;



@class CTVMainMenuElement;


/*
 * CTVMainMenuController
 */
@interface CTVMainMenuController : BRMediaMenuController <CTVSyncListener, CTVAutoUpdateListener>{
	NSMutableArray* m_mainMenuElements; //CTVMainMenuElement*
	CTVMainMenuElement* m_syncMenuItem; //Used by the sync listener
}

-(void)loadMenu;
-(void)unloadMenu:(NSMutableArray*)menuElements;
-(void)syncNow:(CTVMainMenuElement*)menuElement;
-(void)config:(CTVMainMenuElement*)menuElement;

- (id) initWithScene: (BRRenderScene *) scene;
- (void) dealloc;


- (long) itemCount;
- (id<BRMenuItemLayer>) itemForRow: (long) row;
- (NSString *) titleForRow: (long) row;
- (long) rowForTitle: (NSString *) title;
- (void) itemSelected: (long) row;
- (id<BRMediaPreviewController>) previewControllerForItem: (long) item;
- (id)popAnimation;
- (id)pushAnimation;

- (void)willBePopped;
- (void)willBePushed;
- (void)wasExhumedByPoppingController:(id)fp8;

//@protocol CTVSyncListener
-(void)syncStarted;
-(void)syncStopped;
-(void)syncWillFinish; 
-(void)_updateMenu;

//@protocol CTVAutoUpdateListener
-(void)autoUpdateCheckDone:(NSString*)version;	
-(void)autoUpdateCheckFail;		


@end



/*
 * CTVMainMenuElement
 */
@interface CTVMainMenuElement : NSObject{
	NSString* m_title;
	CTVRootChannel* m_rootChannel;
	CTVMainMenuElementType m_type;
	SEL m_function;
	NSString* m_iconName;
}
-(id)init;
-(void)dealloc;
-(void)setTitle:(NSString*)title;
-(NSString*)title;
-(void)setRootChannel:(CTVRootChannel*)rootChannel;
-(CTVRootChannel*)rootChannel;
-(void)setType:(CTVMainMenuElementType)type;
-(CTVMainMenuElementType)type;
-(void)setFunction:(SEL)function;
-(SEL)function;
-(NSString*)iconName;
-(void)setIconName:(NSString*)urlString;

@end
